#include "stm32f10x.h"                  // Device header
#include "OLED.h"
#include "Delay.h"
#include "Serial.h"
#include "LED.h"
#include "string.h"


uint8_t RxData;
char *Packet;


int main(void)
{
	LED_Init();
	Serial_Init();
	OLED_Init();
	Show_Message();
//	Serial_SendByte(0xAA);
	while(1)
	{
//		__WFI();			// 了解唤醒前后程序运行的"流"
		OLED_ShowString(2, 1, "RxData:");
//		Serial_SendString("Hello, LabVIEW!");
//		Delay_ms(3000);
		Packet = RxDataPacket;
		if (RxFlag == 1)
		{				
			OLED_ShowString(2, 8, RxDataPacket);
			if (strcmp(RxDataPacket, "1111") == 0)
			{
				LED1_ON();
				Serial_SendString("LED1_ON is OK \r\n");
			}
			else if (strcmp(RxDataPacket, "2222") == 0)
			{
				LED2_ON();
				Serial_SendString("LED2_ON is OK \r\n");
			}
			else if (strcmp(RxDataPacket, "3333") == 0)
			{
				LED1_OFF();
				LED2_OFF();
				Serial_SendString("ALL LEDs are OFF \r\n");
			}
			RxFlag = 0;
		}
		OLED_ShowString(1, 1, "Ahhhh");
		Delay_ms(100);
		OLED_ShowString(1, 1, "     ");
		Delay_ms(100);
		
		__WFI();
	}
}
